using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EventExample
{
    // 事件的拥有者是事件的响应者的一个成员 重要程度:***
    class Program
    {
        static void Main(string[] args)
        {
            MyForm form = new MyForm();
            form.ShowDialog();
        }
    }
    // 2.事件的响应者
    class MyForm : Form
    {
        // 1.事件拥有者
        private Button button;
        private TextBox textBox;
        public MyForm()
        {
            this.button = new Button();
            this.textBox = new TextBox();
            this.Controls.Add(this.textBox);
            this.Controls.Add(this.button);
            // 3.事件 += (4.事件订阅) 5.事件处理器
            this.button.Click += this.ButtonClicked;
            this.button.Text = "Show";
            this.button.Top = 100;
        }
        private void ButtonClicked(object sender, EventArgs e)
        {
            this.textBox.Text = "MyForm.ButtonClicked:" + DateTime.Now.ToString();
        }
    }
}
